package edu.java.lectures.lec01.main;

public class TestEquals {

    public static void main(String[] args) {

	// primitive types
	System.out.println("------- pritive types -------");
	int aInt = 1;
	int bInt = 1;
	System.out.println("aInt == bInt: " + (aInt == bInt));

	// referent types
	System.out.println("\n------- Object -------");
	Object aObj = new Object();
	Object bObj = new Object();
	System.out.println("aObj == bObj: " + (aObj == bObj));

	// the next line is the same like "aObj == bObj"
	System.out.println("aObj.equals(bObj): " + aObj.equals(bObj));

	// point
	System.out.println("\n------- Point -------");
	Point2D aPoint = new Point2D(3, 5);
	Point2D bPoint = new Point2D(3, 5);
	System.out.println("aPoint == bPoint: " + (aPoint == bPoint));
	System.out.println("aPoint.equals(null): " + aPoint.equals(null));
	System.out.println("aPoint.equals(bPoint): " + aPoint.equals(bPoint));
	System.out.println("aPoint.equals(bObj): " + aPoint.equals(bObj));

	// strings
	System.out.println("\n------- Strings -------");
	String aStr = "aString";
	String aStrLiteralCopy = "aString";
	System.out.println("aStr == aStrLiteralCopy: "
		+ (aStr == aStrLiteralCopy));
	System.out.println("aStr.equals(aStrLiteralCopy): "
		+ aStr.equals(aStrLiteralCopy));

	String aStrConstrCopy = new String("aString");
	System.out.println("aStr == aStrConstrCopy: "
		+ (aStr == aStrConstrCopy));
	System.out.println("aStr.equals(aStrConstrCopy): "
		+ aStr.equals(aStrConstrCopy));

	String bStr = new String("test");
	String cStr = new String("test");
	System.out.println("bStr == cStr: " + (bStr == cStr));
	System.out.println("bStr.equals(cStr): " + bStr.equals(cStr));

	String dStr = new String("a");
	System.out.println("bStr.equals(dStr): " + bStr.equals(dStr));
    }
}
